
package com.flying.cattle.mdg;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import com.gitee.flying.cattle.mdg.entity.BasisInfo;
import com.gitee.flying.cattle.mdg.util.EntityInfoUtil;
import com.gitee.flying.cattle.mdg.util.Generator;
import com.gitee.flying.cattle.mdg.util.MySqlToJavaUtil;
/**   
 * Copyright: Copyright (c) 2019 
 * 
 * <p>说明： 自动生成工具</P>
 * <p>源码地址：https://gitee.com/wailaizhe/mybatis-generator.git</P>
 */
public class MyGenerator {
	// 基础信息：项目名、作者、版本
	public static final String PROJECT = "service-marketing-center";
	public static final String AUTHOR = "石亚宁";
	public static final String VERSION = "V1.0";
	// 数据库连接信息：连接URL、用户名、秘密、数据库名
	public static final String URL = "jdbc:mysql://117.50.127.49:13306/marketing_center?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8";
	public static final String NAME = "mktuser";
	public static final String PASS = "NrcpMktWx#21@123";
	public static final String DATABASE = "marketing_center";
	// 类信息：类名、对象名（一般是【类名】的首字母小些）、类说明、时间
	//public static final String CLASSNAME = "SystemSetting";
	//可以多个表一起生成
	public static final String[] TABLES = new String[]{"mid_customer_app_recharge","app_recharge_type"};
	public static final String CLASSCOMMENT = "充值有礼";
	public static final	Date d = new Date();
	public static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
	public static final String TIME = sdf.format(d) ;
	public static final String AGILE = new Date().getTime() + "";
	// 路径信息，分开路径方便聚合工程项目，微服务项目
	public static final String prefix="cn.ce.marketingcenter." ;
	public static final String ENTITY_URL = prefix+"entity";
	public static final String DAO_URL = prefix+"dao";
	public static final String XML_URL =  prefix+"mapper.2";
	public static final String SERVICE_URL = prefix+ "service";
	public static final String SERVICE_IMPL_URL = prefix+ "service.impl";
	public static final String CONTROLLER_URL = prefix+ "controller";
	//是否是Swagger配置
	public static final String IS_SWAGGER = "true";

	public static void main(String[] args) {
		List<String> strings = Arrays.asList(TABLES);
		for (String table : strings) {
			create(table);
		}

	}


	public static void create(String table) {
		BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL,
				DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL, IS_SWAGGER);
		bi.setTable(table);
		bi.setEntityName(MySqlToJavaUtil.getClassName(table));
		bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(table));
		bi.setEntityComment(CLASSCOMMENT);

		try {
			bi = EntityInfoUtil.getInfo(bi);
			String fileUrl = "D:\\mkt\\service-marketing-center\\src\\main\\java\\";// 生成文件存放位置
			//开始生成文件
			//	String aa1 = Generator.createEntity(fileUrl, bi).toString();
			 //String aa2 = Generator.createDao(fileUrl, bi).toString();
			String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
				//String aa4 = Generator.createService(fileUrl, bi).toString();
				//String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
				String aa6 = Generator.createController(fileUrl, bi).toString();
			// 是否创建swagger配置文件
			//	String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();

			//System.out.println(aa1);
			//System.out.println(aa2); System.out.println(aa3); System.out.println(aa4);
			//System.out.println(aa5); System.out.println(aa6); System.out.println(aa7);

			//System.out.println(aa7);
		} catch (SQLException e) {
			e.printStackTrace();


	}
	}
}